<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../../css/utils/bootstrap.min.css" />
    <link rel="stylesheet" href="../../css/utils/common.css" />
    <link rel="stylesheet" href="../../css/utils/toastr.min.css" />
	<title></title>
	<style>
		.col-top {
			margin-top: 100px;
		}
		.col-top .form-group {
			margin-bottom: 25px;
		}
		.text-red {
		    color: #ee4747;
		}
		.no-padder {
		    padding: 0 !important;
		}
		.btn-primary:focus, .btn-primary:hover {
			color: #fff;
			background-color: #2aeee2;
			border-color: #2aeee2;
		}
		.btn-primary {
		    color: #fff;
		    background-color: #11B5AB;
		    border-color: #11B5AB;
		}
		.cancle {
			color: #7B7B7B;
			background-color: #F3F3F3;
		    border-color: #F3F3F3;
		}
		.col-align {
			text-align: center;
		}
		.btn-width {
			padding: 6px 50px;
		}
		#accountModify {
			display: none;
		}
		#payModify {
			display: none;
		}
		/*-------------公众号设置------------*/
		.QRCode-div {
			margin-left: 217px;
			width: 167px;
			height: 167px;
			background-image: url(../../img/myExtension/checkbox-false.png);
			background-size: 100% 100%;
		}
		.tips-pay {
			width: 640px;
			height: 700px;
		}
		.tips-align {
			text-align: center;
		}
		.tips-pay-div {
			font-size: 16px;
			color: #666666;
			font-family: "MicrosoftYaHei";
		}
		#pwdValidata {
			display: none;
		}
		.wechat-qrcode {
			height: 120px;
		}
		.wechat-qrcode label {
		    text-align: right;
    			margin-top: 40px;
		}
	</style>
</head>
<body>
	<div class="content">
		<div class="tab-pane">
			<div class="btn-group btn-group-justified btn-tab-sm" role="group" aria-label="button-group">
				<div class="btn-group" role="group">
					<button type="button" panel-data="tab-sm-panel1" class="btn btn-default active">公众号绑定设置</button>
				</div>
				<div class="btn-group" role="group">
					<button type="button" panel-data="tab-sm-panel2" class="btn btn-default">公司支付设置</button>
				</div>
			</div>
			<div class="tab-sm-content">
				<div id="tab-sm-panel1" class="tab-sm-pane active">
					<div id="accountPreview" class="col-md-offset-3 col-md-6 col-top">
						<div class="wechat-qrcode">
							<label class="control-label col-md-5 "> 公司头像：</label>
							<div class="control-label col-md-5">
				                 <img id="companyImg" class="avatar c-p" style="position: absolute; width:100px; height:100px; border-radius: 0;" />
				            </div>
						</div>
						<div class="wechat-qrcode">
							<label class="control-label col-md-5 "> 公众号二维码：</label>
							<div class="control-label col-md-5" title="点击修改二维码">
				                 <img id="qrcodeImg" class="avatar c-p" style="position: absolute; width:100px; height:100px; border-radius: 0;" />
				            </div>
						</div>
						<div class="form-horizontal">
							<div class="form-group col-align">
								<label class="control-label col-md-5"> 微信公众号名称：</label>
								<label id="weChatName" class="control-label col-md-5" style="text-align: left;"> </label>
							</div>
							<div class="form-group col-align">
								<label class="control-label col-md-5"> App ID：</label>
								<label id="appId" class="control-label col-md-5" style="text-align: left;"> </label>
							</div>
							<div class="form-group col-align">
								<label class="control-label col-md-5"> App Secret：</label>
								<label id="appSecret" class="control-label col-md-5" style="text-align: left;"> </label>
							</div>
							<div class="form-group col-align">
								<label class="control-label col-md-5"> 绑定域名：</label>
								<label id="domainName" class="control-label col-md-5" style="text-align: left;"> </label>
							</div>
							<div class="form-group col-align">
								<button type="submit" class="btn btn-primary btn-width" data-toggle="modal" data-target="#modifyAccountBindModal">更换绑定</button>
							</div>
						</div>
					</div>
					<div id="accountModify" class="col-md-offset-3 col-md-6 col-top">
						<form class="form-horizontal" id="accountForm">
							<div class="wechat-qrcode">
								<label class="control-label col-md-4 "> 公司头像：</label>
								<div class="col-md-6 upload-btn100" id="qrcodeContainer">
					                 <img id="companyHeaderUploader" class="avatar c-p" style="position: absolute; width:100px; height:100px; border-radius: 0;" />
					                 <input type="hidden" value="" name="companyHeader" id="companyHeader">
					                 <a class="file-a">
					                 	<input type="file" name="eidtorCompanyHeader" value="" accept="image/*" multiple onchange="imgHandleInputChange(this);" />	
					                 </a>
					            </div>
							</div>
							<div class="wechat-qrcode">
								<label class="control-label col-md-4 "> 公众号二维码：</label>
								<div class="col-md-6 upload-btn100" title="点击修改二维码" id="qrcodeContainer">
					                 <img id="qrcodeUploader" class="avatar c-p" style="position: absolute; width:100px; height:100px; border-radius: 0;" />
					                 <input type="hidden" value="" name="companyQrcode" id="companyQrcode">
					                 <a class="file-a">
					                 	<input type="file" name="eidtorQrcode" value="" accept="image/*" multiple onchange="imgHandleInputChange(this);" />	
					                 </a>
					            </div>
							</div>
							<div class="form-group">
								<label for="recipient-name" class="control-label col-md-4"><span class="text-red">*</span> 微信公众号名称：</label>
								<div class="col-md-6 no-padder">
									<input id="weChatNameInput" name="weChatNameInput" class="form-control" placeholder="请输入微信公众号名称" required="required"/>
								</div>
							</div>
							<div class="form-group">
								<label for="message-text" class="control-label col-md-4"><span class="text-red">*</span> App ID：</label>
								<div class="col-md-6 no-padder">
									<input id="appIdInput" name="appIdInput" class="form-control" placeholder="请输入公众号App ID" required="required"/>
								</div>
							</div>
							<div class="form-group">
								<label for="message-text" class="control-label col-md-4"><span class="text-red">*</span> App Secret：</label>
								<div class="col-md-6 no-padder">
									<input id="appSecretInput" name="appSecretInput" class="form-control" placeholder="请输入App Secret" required="required"/>
								</div>
							</div>
							<div class="form-group">
								<label for="message-text" class="control-label col-md-4"><span class="text-red">*</span> 绑定域名：</label>
								<div class="col-md-6 no-padder">
									<input id="domainNameInput" name="domainNameInput" class="form-control" placeholder="请输入绑定域名" required="required"/>
								</div>
							</div>
							<div class="form-group">
								<div class="col-md-offset-4 col-md-6 no-padder">
									<button type="button" id="cancleAccount" class="btn btn-primary btn-width cancle" >取消</button>
									<button type="submit" id="saveAccount" class="btn btn-primary btn-width" >保存</button>
								</div>
							</div>
						</form>
					</div>
				</div>
				<div id="tab-sm-panel2" class="tab-sm-pane">
					<div id="payPreview" class="col-md-offset-3 col-md-6 col-top">
						<div class="form-horizontal">
							<div class="form-group col-align">
								<label class="control-label col-md-5"> 微信支付商户号：</label>
								<label id="paiAccount" class="control-label col-md-5" style="text-align: left;"> </label>
							</div>
							<div class="form-group col-align">
								<label class="control-label col-md-5"> API密钥：</label>
								<label id="paiAPIkey" class="control-label col-md-5" style="text-align: left;"> </label>
							</div>
							<div class="form-group col-align">
								<label class="control-label col-md-5"> API证书文件(apiclient_cert.p12)：</label>
								<label id="paiAPICert12" class="control-label col-md-5" style="text-align: left;"> </label>
							</div>
							<div class="form-group col-align">
								<label class="control-label col-md-5"> API证书文件(apiclient_cert.pem)：</label>
								<label id="paiAPICertpem" class="control-label col-md-5" style="text-align: left;"> </label>
							</div>
							<div class="form-group col-align">
								<label class="control-label col-md-5"> API证书文件(apiclient_key.pem)：</label>
								<label id="paiAPIKeypem" class="control-label col-md-5" style="text-align: left;"> </label>
							</div>
							<div class="form-group col-align">
								<button type="submit" class="btn btn-primary btn-width"  data-toggle="modal" data-target="#modifyPayBindModal">更换绑定</button>
							</div>
						</div>
					</div>
					<div id="payModify" class="col-md-offset-3 col-md-6 col-top">
						<form class="form-horizontal" id="payForm">
							<div class="form-group">
								<label for="recipient-name" class="control-label col-md-4"><span class="text-red">*</span> 微信支付商户号：</label>
								<div class="col-md-6 no-padder">
									<input id="paiAccountInput" name="paiAccountInput" class="form-control" placeholder="微信支付商户号" required="required"/>
								</div>
							</div>
							<div class="form-group">
								<label for="message-text" class="control-label col-md-4"><span class="text-red">*</span> API密钥：</label>
								<div class="col-md-6 no-padder">
									<input id="paiAPIkeyInput" name="paiAPIkeyInput" class="form-control" placeholder="请输入公众号App ID" required="required"/>
								</div>
							</div>
							<div class="form-group">
								<label for="message-text" class="control-label col-md-4"><span class="text-red">*</span> API证书文件(apiclient_cert.p12)：</label>
								<div class="col-md-6 no-padder">
									<input type="file" name="APICert12" class="form-control" onchange="handleInputChange(this);" />
									<input id="paiAPICert12Input" name="paiAPICert12Input" type="hidden" class="form-control" required="required"/>
								</div>
							</div>
							<div class="form-group">
								<label for="message-text" class="control-label col-md-4"><span class="text-red">*</span> API证书文件(apiclient_cert.pem)：</label>
								<div class="col-md-6 no-padder">
									<input type="file" name="APICertpem1" class="form-control" onchange="handleInputChange(this);" />
									<input id="paiAPICertpemInput" name="paiAPICertpemInput" type="hidden" class="form-control" required="required"/>
								</div>
							</div>
							<div class="form-group">
								<label for="message-text" class="control-label col-md-4"><span class="text-red">*</span> API证书文件(apiclient_key.pem)：</label>
								<div class="col-md-6 no-padder">
									<input type="file" name="APICertpem2" class="form-control" onchange="handleInputChange(this);" />
									<input id="paiAPIKeypemInput" name="paiAPIKeypemInput" type="hidden" class="form-control" required="required"/>
								</div>
							</div>
							<div id="pwdValidata" class="form-group">
								<label for="message-text" class="control-label col-md-4"><span class="text-red">*</span> 登录密码：</label>
								<div class="col-md-6 no-padder">
									<input type="password" id="passwordValidation" name="passwordValidation" class="form-control" placeholder="请输入登录密码验证" required="required"/>
								</div>
							</div>
							<div class="form-group">
								<div class="col-md-offset-4 col-md-6 no-padder">
									<button type="button" id="canclePay" class="btn btn-primary btn-width cancle" >取消</button>
									<button type="submit" id="savePay" class="btn btn-primary btn-width" >保存</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
		<div class="modal fade bs-example-modal-sm" id="modifyAccountBindModal" tabindex="-1" role="dialog" aria-labelledby="modifyAccountBindModalLabel">
	        <div class="modal-dialog modal-sm">
	            <div class="modal-content">
	                <div class="modal-header">
	                	<!--<input type= "hidden"  id = "delArticleId" value=""/>-->
	                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	                    <h4 class="modal-title">温馨提示</h4>
	                </div>
	                <div class="modal-body">
	                  	  确定要更换绑定吗?更换不成功会影响内容分享发布查阅!
	                </div>
	                <div class="modal-footer">
	                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
	                    <button type="button" class="btn btn-primary" data-dismiss="modal" id="modifyAccountBind">确定</button>
	                </div>
	            </div>
	        </div>
	    </div>
	    <div class="modal fade bs-example-modal-sm" id="modifyPayBindModal" tabindex="-1" role="dialog" aria-labelledby="modifyPayBindModalLabel">
	        <div class="modal-dialog modal-sm">
	            <div class="modal-content">
	                <div class="modal-header">
	                	<!--<input type= "hidden"  id = "delArticleId" value=""/>-->
	                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	                    <h4 class="modal-title">温馨提示</h4>
	                </div>
	                <div class="modal-body">
	                  	  确定要更换绑定吗?更换不成功会影响内容商品插件和红包功能的金额往来!
	                </div>
	                <div class="modal-footer">
	                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
	                    <button type="button" class="btn btn-primary" data-dismiss="modal" id="modifyPayBind">确定</button>
	                </div>
	            </div>
	        </div>
	    </div>
	</div>
	
	<script type="text/javascript" src="../../js/utils/jquery-1.12.4.min.js" ></script>
	<script type="text/javascript" src="../../js/utils/bootstrap.min.js" ></script>
	<script type="text/javascript" src="../../js/utils/bootstrap-treeview.js" ></script>
	<script type="text/javascript" src="../../js/utils/jquery.cookie.js" ></script>
	<script type="text/javascript" src="../../js/utils/jquery.validate.min.js?version=1" ></script>
	<script type="text/javascript" src="../../js/utils/page.js" ></script>
	<script type="text/javascript" src="../../js/utils/boot.js" ></script>
	<script type="text/javascript" src="../../js/utils/toastr.min.js" ></script>
	<script type="text/javascript" src="../../js/utils/depart.js" ></script>
	<script>
		var userID = $.cookie("userID");
		var companyID = $.cookie("companyID");
		var companyName = $.cookie("companyName");
		var isAdmin = $.cookie("isAdmin");
		var wechatID,wechatPayID;
		$(function() {
			toastr.options = {
                "closeButton": true,
                "timeOut": 2000,
                "positionClass": "toast-center"
         	};
         	getCompanyWeChatSet();
		})
		$("#accountForm").validate({
	       	rules:{
	       		weChatNameInput: {
	       			required:true,
	       		},
				appIdInput:{
					required:true,
				},
				appSecretInput:{
					required:true,
				},
				domainNameInput:{
					required:true,
				} 
	       	},
	       	messages:{
	       		weChatNameInput: {
	       			required: "请输入公众号名称",
	       		},
	          	appIdInput:{
	               	required: "请输入App ID",
	           	},
	          	appSecretInput:{
					required: "请输入App Secret",
	           	},
	          	domainNameInput:{
					required: "请输入绑定域名",
	           	}                                     
	       },
	       submitHandler: function() {
				var data = {
					id: wechatID,
					userID:userID,
					companyID:companyID,
					wechatName:$("#weChatNameInput").val(),
					appId:$("#appIdInput").val(),
					appSecret:$("#appSecretInput").val(),
					domainName:$("#domainNameInput").val(),
					qrCodeUrl:$("#companyQrcode").val(),
					companyHeadUrl:$("#companyHeader").val()
				}
				base.postData(base.url.addCompanyWeChat, data, function(data) {
					if (data.success) {
						$("#weChatName").text($("#weChatNameInput").val());
						$("#appId").text($("#appIdInput").val());
						$("#appSecret").text($("#appSecretInput").val());
						$("#domainName").text($("#domainNameInput").val());
						$("#accountPreview").show();
						$("#accountModify").hide();
						toastr.success(data.msg);
					} else {
						toastr.error(data.msg);
					}
				});
		    }
		})
		$("#payForm").validate({
	       	rules:{
	       		paiAccountInput: {required:true},
				paiAPIkeyInput: {required:true},
				paiAPICert12Input: {required:true},
				paiAPICertpemInput: {required:true},
				paiAPIKeypemInput: {required:true}
	       	},
	       	messages:{
	       		paiAccountInput: {required: "请输入公众号名称"},
	          	paiAPIkeyInput:{required: "请输入API密钥"},
	          	paiAPICert12Input:{required: "请上传.p12的证书文件"},  
	          	paiAPICertpemInput:{required: "请上传.pem的证书文件"},  
	          	paiAPIKeypemInput:{required: "请上传.pem的证书文件"},  
	       },
	       submitHandler: function() {
	       		var _apiclientCertP12 = $("#paiAPICert12Input").val();
	       		var _apiclientCertPem = $("#paiAPICertpemInput").val();
	       		var _apiclientKeyPem = $("#paiAPIKeypemInput").val();
				var data = {
					id: wechatPayID,
					userID:userID,
					companyID:companyID,
					merchantNo:$("#paiAccountInput").val(),
					apiSecretKey:$("#paiAPIkeyInput").val(),
					apiclientCertP12:_apiclientCertP12,
					apiclientCertPem:_apiclientCertPem,
					apiclientKeyPem:_apiclientKeyPem,
					pwd: $("#passwordValidation").val()
				}
				base.postData(base.url.addCompanyPay, data, function(data) {
					if (data.success) {
						$("#passwordValidation").val("");//修改成功后重新初始化密码输入框
						$("#paiAccount").text($("#paiAccountInput").val());
						$("#paiAPIkey").text($("#paiAPIkeyInput").val());
						if (_apiclientCertP12) {
							if (_apiclientCertP12.indexOf(".p12") != -1) {
								var tempApiclientCertP12 = _apiclientCertP12.split("html")[1];
								$("#paiAPICert12").text(tempApiclientCertP12);
							}
						}
						if (_apiclientCertPem) {
							if (_apiclientCertPem.indexOf(".pem") != -1) {
								var tempApiclientCertPem = _apiclientCertPem.split("html")[1];
								$("#paiAPICertpem").text(tempApiclientCertPem);
							}
						}
						if (_apiclientKeyPem) {
							if (_apiclientKeyPem.indexOf(".pem") != -1) {
								var tempApiclientKeyPem = _apiclientKeyPem.split("html")[1];
								$("#paiAPIKeypem").text(tempApiclientKeyPem);
							}
						}
						$("#payPreview").show();
						$("#payModify").hide();
						toastr.success(data.msg);
					} else {
						toastr.error(data.msg);
					}
				});
		    }
		})
		function getCompanyWeChatSet () {
			base.postData(base.url.companyWeChatSet, {userID:userID,companyID:companyID}, callbackCompanyWeChatSet);	
		}
		function callbackCompanyWeChatSet(data) {
			if (data.success) {
				wechatID = data.context.companyWeChat.id;
				$("#companyQrcode").val(data.context.companyWeChat.qrCodeUrl);
				$("#companyHeader").val(data.context.companyWeChat.companyHeadUrl);
				$("#qrcodeImg").attr("src", data.context.companyWeChat.qrCodeUrl||"../../img/myExtension/upload_img.png");
				$("#companyImg").attr("src", data.context.companyWeChat.companyHeadUrl||"../../img/myExtension/upload_img.png");
				$("#qrcodeUploader").attr("src", data.context.companyWeChat.qrCodeUrl||"../../img/myExtension/upload_img.png");
				$("#companyHeaderUploader").attr("src", data.context.companyWeChat.companyHeadUrl||"../../img/myExtension/upload_img.png");
				$("#weChatName").text(data.context.companyWeChat.wechatName);
				$("#appId").text(data.context.companyWeChat.appId);
				$("#appSecret").text(data.context.companyWeChat.appSecret);
				$("#domainName").text(data.context.companyWeChat.domainName);
				$("#weChatNameInput").val(data.context.companyWeChat.wechatName);
				$("#appIdInput").val(data.context.companyWeChat.appId);
				$("#appSecretInput").val(data.context.companyWeChat.appSecret);
				$("#domainNameInput").val(data.context.companyWeChat.domainName);
			}
		}
		function getCompanyPaySet () {
			base.postData(base.url.companyPaySet, {userID:userID,companyID:companyID}, callbackCompanyPaySet);	
		}
		function callbackCompanyPaySet(data) {
			if (data.success) {
				wechatPayID = data.context.merchantNumber.id;
				$("#paiAccount").text(data.context.merchantNumber.merchantNo);
				$("#paiAPIkey").text(data.context.merchantNumber.apiSecretKey);
				$("#paiAccountInput").val(data.context.merchantNumber.apiSecretKey);
				$("#paiAPIkeyInput").val(data.context.merchantNumber.apiSecretKey);
				if (data.context.merchantNumber.apiclientCertP12) {
					if (data.context.merchantNumber.apiclientCertP12.indexOf(".p12") != -1) {
						var _apiclientCertP12 = data.context.merchantNumber.apiclientCertP12.split("html")[1];
						$("#paiAPICert12").text(_apiclientCertP12);
						$("#paiAPICert12Input").val(data.context.merchantNumber.apiclientCertP12);
					}
				}
				if (data.context.merchantNumber.apiclientCertPem) {
					if (data.context.merchantNumber.apiclientCertPem.indexOf(".pem") != -1) {
						var _apiclientCertPem = data.context.merchantNumber.apiclientCertPem.split("html")[1];
						$("#paiAPICertpem").text(_apiclientCertPem);
						$("#paiAPICertpemInput").val(data.context.merchantNumber.apiclientCertPem);
					}
				}
				if (data.context.merchantNumber.apiclientKeyPem) {
					if (data.context.merchantNumber.apiclientKeyPem.indexOf(".pem") != -1) {
						var _apiclientKeyPem = data.context.merchantNumber.apiclientKeyPem.split("html")[1];
						$("#paiAPIKeypem").text(_apiclientKeyPem);
						$("#paiAPIKeypemInput").val(data.context.merchantNumber.apiclientKeyPem);
					}
				}
			}
			if (wechatPayID) {
				$("#pwdValidata").show();
			}
		}
        //上传文件
		function handleInputChange(obj){
			var fileData = event.target.files[0];
			if ($(obj).attr("name") == "APICert12") {
				// 检查文件类型
			    if('p12'.lastIndexOf(fileData.name.split(".")[1]) < 0){
			        toastr.warning("文件类型仅支持 p12！");
			        return;
			    }
			} else {
				// 检查文件类型
			    if('pem'.lastIndexOf(fileData.name.split(".")[1]) < 0){
			        toastr.warning("文件类型仅支持 pem！");
			        return;
			    }
			}
			uploadFile(obj,fileData);
		}
		//上传文件
		function uploadFile(obj,files){
			toastr.info("正在上传，请稍等...");
			var formData = new FormData();
			formData.append('type', 1);
			formData.append('file', files);
			formData.append('companyID', companyID);
			$.ajax({
	            url: base.url.fileUpload,
	            method: 'POST',
	            data: formData,
	            contentType: false, // 注意这里应设为false
	            processData: false,
	            cache: false,
	            success: function(data) {
	            		toastr.success("文件上传成功！");
	            		if ($(obj).attr("name") == "APICert12") {
	            			$("#paiAPICert12Input").val(data.context.fileUrl);
	            		} else if ($(obj).attr("name") == "APICertpem1") {
	            			$("#paiAPICertpemInput").val(data.context.fileUrl);
	            		} else {
	            			$("#paiAPIKeypemInput").val(data.context.fileUrl);
	            		}
	            },
	            error: function (jqXHR) {
	                toastr.warning(JSON.stringify(jqXHR));
	            }
	        })
		}
		$("#modifyAccountBind").on("click", function() {
			$("#accountPreview").hide();
			$("#accountModify").show();
		})
		$("#modifyPayBind").on("click", function() {
			$("#payPreview").hide();
			$("#payModify").show();
		})
		$(".btn-tab-sm").on("click", "button", function(){
			$(".btn-tab-sm button").removeClass("active");
			$(this).addClass("active");
			var panelId = $(this).attr("panel-data");
			if (panelId == "tab-sm-panel1") {
				getCompanyWeChatSet();
			} else {
				getCompanyPaySet();
			}
			$(".tab-sm-content .tab-sm-pane").removeClass("active");
			$("#"+panelId).addClass("active");
		});
		$("#accountModify").on("click", "#cancleAccount", function() {
			$("#accountPreview").show();
			$("#accountModify").hide();
		})
		$("#payModify").on("click", "#canclePay", function() {
			$("#payPreview").show();
			$("#payModify").hide();
		})
		//上传INPUT图片
		function imgHandleInputChange(obj){
			//先判断是否已有五张图片
			var fileData = event.target.files[0];
			var imgMasSize = 1024 * 1024 * 5; // 5MB
			// 检查文件类型
		    if(['jpeg', 'png', 'gif', 'jpg', 'bmp'].indexOf(fileData.type.split("/")[1]) < 0){
		        toastr.warning("文件类型仅支持 jpeg/png/gif/jpg!");
		        return;
		    }
		    // 文件大小限制
		    if(fileData.size > imgMasSize ) {
		        // 文件大小自定义限制
		        toastr.warning("文件大小不能超过5MB！");
		        return;
		    }
			imgUploadFile(obj,fileData);
		}
		//上传图片
		function imgUploadFile(obj,files){
			toastr.info("正在上传，请稍等...");
			var formData = new FormData();
			formData.append('Filedata', files);
			formData.append('type', 1);
			$.ajax({
	            url: base.url.uploadFile,
	            method: 'POST',
	            data: formData,
	            contentType: false, // 注意这里应设为false
	            processData: false,
	            cache: false,
	            success: function(data) {
	            console.log(data.obj);
	            		pingFileData(obj, data.obj);
	            },
	            error: function (jqXHR) {
	                toastr.warning(JSON.stringify(jqXHR));
	            }
	        })
		}
		function pingFileData(obj, fileUrl){
			if ($(obj).attr("name") == "eidtorCompanyHeader") {
				$("#companyHeader").val(fileUrl);
				$("#companyHeaderUploader").attr("src", fileUrl);
				$("#companyImg").attr("src", fileUrl);
			} else if ($(obj).attr("name") == "eidtorQrcode") {
				$("#companyQrcode").val(fileUrl);
				$("#qrcodeUploader").attr("src", fileUrl);
				$("#qrcodeImg").attr("src", fileUrl);
			}
		}
	</script>
</body>
</html>
